<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>后台管理</title>
{{include file="layouts/_head"}}
<link rel="stylesheet" type="text/css" href="/static/admin/style/freight.css" />
</head>
<body>
<div class="main">
	<ol class="breadcrumb">
		<li><i class="icon_home iconfont"></i>首页</li>
	  	<li>订单物流</li>
	  	<li><a href="javascript:history.go(-1);">运费模板</a></li>
	  	<li class="active">创建运费模板</li>
	</ol>
	<div class="bg-danger clearfix main-head-info error-info"></div>
	<div class="main-con">
		<form class="form-horizontal margin-t-30" id="form" method="post" action="{{:url('/admin/shipping_freight/store')}}" >
		  	<div class="tab-box">	
			  	<div class="form-group">
			    	<span class="col-sm-2 control-label"><span class="color-red">*</span> 模板名称：</span>
			    	<div class="col-sm-8 input-group"><input class="form-control" name="name"></div>
			  	</div>
			  	<div class="form-group">
				    <span class="col-sm-2 control-label">简要描述：</span>
				    <div class="col-sm-8 input-group">
				      <textarea class="form-control" rows="3" name="description"></textarea>
				    </div>
				</div>
			    <div class="form-group">
				    <span class="col-sm-2 control-label"><span class="color-red">*</span> 计价方式：</span>
				    <div class="col-sm-2 input-group ">
				    	<div class="radio" id="types">
				    		<label><input type="radio" name="type" value="1">件数</label>
				    		<label><input type="radio" name="type" value="2">重量</label>
				    		<label><input type="radio" name="type" value="3">体积</label>
				    	</div>
				    </div>
			    </div>
			    <div class="form-group">
				    <span class="col-sm-2 control-label">启用默认：</span>
				    <div class="col-sm-2 input-group ">
				    	<div class="radio">
				    		<label><input type="radio" name="default_type" value="0">否</label>
				    		<label><input type="radio" name="default_type" value="1">是</label>
				    	</div>
				    </div>
			    </div>
			</div>
			<table class="table table-bordered table-hover none" id="freight"></table>
			<div class="foot_btn_blank"></div>
            <div class="foot_btn">
                <div class="box">
                    <button type="submit" class="btn btn-primary">提交信息</button>
                </div>
            </div>
		</form>
	</div>
</div>
{{include file='shipping_freight/_ship_area'}}
{{include file="layouts/_foot"}}
{{include file="shared/_jquery_validation"}}
<script type="text/javascript" src="/static/admin/script/freight.js"></script>
<script type="text/javascript">
$("#form").validate({
	rules: {
		name: {required: true},
		type: {required: true},
		freight_way_id: {required: true}
	},
	messages: {
		name: '模板名称不能为空',
		type: '计价方式不能为空',
	},
	submitHandler:function(){
		layer.confirm('确认提交？', function() {
			layer.closeAll(); var load = layer.load();
			$("#form").ajaxSubmit(function(res) {
                layer.close(load);
                if (res.code == 401) {
                    goLogin(); return false;
                }
                if (res.code == 200) {
                    layer.msg('提交成功', {time: 1500}, function() {window.location.href = '{{:url("/admin/shipping_freight")}}'});
                } else if (res.code == 400) {
                    layer.msg(res.message); return false;
                } else {
                    layer.msg('操作失败'); return false;
                }
			});
		});
	}
});
</script>
</body>
</html>